Python: 4 Books in 1: Beginner's Guide + Tips and Tricks + Best Practices + Advanced Guide to Programming Code with Python by Charlie Masterson

Python: 4 Books in 1: Beginner's Guide + Tips and Tricks + Best Practices + Advanced Guide to Programming Code with Python by Charlie Masterson

Author:Charlie Masterson [Masterson, Charlie]
Language: eng
Format: mobi
Published: 2017-03-16T00:00:00+00:00


Restore health

Change weapons

Exit

Here’s how mine ended up looking:

for i in range(len(p.attackList)):

print "Enter %d to use the move: %s" % (i, p.attackList[i].name)

print "Enter %d to max your HP." % len(p.attackList)

print "Enter %d to change weapons." % (len(p.attackList) + 1)

print "Enter %d to exit." % (len(p.attackList) + 2)

After that, we get the player’s input and parse it, acting accordingly.

if playerIn < len(p.attackList):

attackTurn(p.attackList[playerIn], p, currentEnemy)

elif playerIn == len(p.attackList):

p.health = 50

elif playerIn == (len(p.attackList) + 1):

changeWeapons(p)

elif playerIn == (len(p.attackList) + 2):

run = False

else:

"That's not a valid input.

"



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.